Rendering apparatus, rendering processing method and computer program product

ABSTRACT

A setup section acquires vertex data including at least homogeneous coordinate and window coordinate relevant to two vertexes of rendering primitive, that is, segment. An edge coefficient calculation unit calculates an edge coefficient used for determining whether or not a pixel exists inside a projection area (parallelogram) of the segment. A bounding box calculation unit calculates a bounding box of the projection area from at least one vertex data of two vertexes and the edge coefficient. A start point determination unit classifies the projection area based on a combination of the edge coefficient, and determines scan start point and scan performing direction of the bounding box in accordance with the classification. An edge function initial value determination unit determines an edge function of the pixel corresponding to the scan start point as an initial value, and carries out a DDA, and thereby, generates setup data for rasterizing.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of application Ser. No. 11/147,326,filed Jun. 8, 2005, which is based upon and claims the benefit ofpriority from prior Japanese Patent Application No. 2004-171258, filedJun. 9, 2004. The entire contents of all of the above applications areincorporated herein by reference.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The present invention relates to rendering apparatus (engine), renderingprocessing method and computer program product, which carry outrendering processing of a three-dimensional computer graphics(three-dimensional (3-D) CG) image. In particular, the present inventionrelates to rasterizing if rendering primitive includes a segment havinga vertex existing backwardly from the viewpoint.

2. Description of the Related Art

Three-dimensional CG is a technique of representing and arrangingvarious objects in a computer virtual three-dimensional space bymodeling, and drawing how these objects are seen from viewpoints set inthe space in a two-dimensional screen.

In particular, the technique of drawing objects in the two-dimensionalscreen calls rendering. The rendering includes various processingsdescribed below. Specifically, the processings are setting of viewpointand light source, predetermined coordinate transformation,hidden-surface elimination, shadowing, viewport conversion,anti-aliasing, etc. A processor (engine), which carries out theforegoing rendering at high speed and drawing an image in real time,calls a real-time CG processor (engine).

According to the foregoing rendering, it must be determined whether ornot a pixel to be drawn exists inside rendering primitive. Thus, inorder to express the shape of the rendering primitive with a linearfunction couple, the following calculation is made.

For example, if rendering primitive is a triangle, the shape of thetriangle is expressed using three linear functions shown in thefollowing equation (1).

A0(X,Y)=a0×(X·X0)+b0×(Y·Y0)

A1(X,Y)=a1×(X·X1)+b0×(Y·Y1)

A2(X,Y)=a2×(X·X2)+b0×(Y·Y2)  (1)

Where

(X, Y): pixel window coordinate (i.e., coordinate on two-dimensionalcoordinate system set in viewport

(X0, Y0), (X1, Y1), (X2, Y2): window coordinate of the vertex of thetriangle a0, b0, a1, b1, a2, b2: constant

The foregoing linear functions call an edge function, and the pixel on aviewport (graphic area) is classified into three areas, that is, inside,side and outside of the triangle. In this case, the pixel having an edgefunction value larger than 0 means that it exists inside the triangle.The pixel having an edge function value equal to 0 means that it existson the side of the triangle. The pixel having an edge function valuesmaller than 0 implies that it exists outside the triangle.

Therefore, in rasterizing, it is determined whether or not the edgefunction values on three sides are all large than 0. By doing so, it isdetermined whether or not the pixel exists inside the triangle.Incidentally, coefficients a0, b0, a1, b1, a2 and b2 are calculatedusing the following equation (2).

a0=Y0·Y1

b0=X1·X0

a1=Y1·Y2

b1=X2·X1

a2=Y2·Y0

b2=X0·Y2  (2)

In this case, the vertex (X0, Y0), (X1, Y1), (X2, Y2) of the triangle isarranged on the viewport in the counterclockwise direction.

In order to load the foregoing calculation procedures to hardware, amethod calling DDA (Digital Differential Analysis) is often employed.According to the DDA, only initial value of the edge function in a startpixel is calculated using the equation (1). The foregoing coefficientsa0, b0, a1, b 1, a2 and b2 of the edge function are successively addedto the initial value. In this manner, edge function values ofneighboring pixels are obtained. Moreover, the DDA is often used for theprocedure of interpolating a vertex parameter to calculate a pixelparameter. The contents of the DDA are as follows.

First, a parameter initial value in the start pixel (X, Y) is calculatedusing the following parameter function equation (3).

P(X,Y)=a×X+b×Y+c  (3)

Where,

(X, Y): window coordinate of pixel

a, b and c: coefficient of parameter function

If the rendering primitive is a triangle, the following simultaneouslinear equation (4) is solved to calculate the foregoing coefficients a,b and c.

a×X0+b×Y0+c=p0

a×X1+b×Y1+c=p1

a×X2+b×Y2+c=p2  (4)

Where,

(X0, Y0), (X1, Y1), (X2, Y2): window coordinate of the vertex of thetriangle p0, p1, p2: parameter value representing arbitrary attribute ofthe corresponding vertex

In this case, the foregoing coefficients a, b and c must be calculatedevery kind of parameter.

According the DDA, the coefficients a and b calculated by the equation(4) are added to the initial value calculated by the equation (3),thereby obtaining parameters of neighboring pixels. The calculationsdescribed above are made, and thereby, the following processings arecarried out. One is determination whether or not the pixel exists insiderendering primitive. Another is interpolation of interpolating thevertex parameter to obtain pixel parameter.

In order to effectively achieve the foregoing determination andinterpolation, it is important to select processing target pixel withoutwaste as much as possible. Thus, some methods of effectively scanningthe processing target pixel have been proposed.

The most popular method is a method of scanning the processing targetpixel every rectangular area calling a stamp. The stamp is a rectangulararea where pixels parallel-processed at one cycle in rasterizing arecollected. For example, the stamp size is 8×8 pixels as seen from FIG.13 disclosed in JPN. PAT. APPLN. KOAKI Publication No. 2003-423797. Inthis case, 64 pixels are parallel-processed for one cycle inrasterizing, and moved every cycle to scan the viewport, therebygenerating pixel data.

FIG. 26-1 of JPN. PAT. APPLN. KOAKI Publication No. 2003-423797, thereis shown the procedure of scanning a triangle rendering primitive usinga rectangular stamp. As seen from FIG. 26-1, the stamp is moved on theline along the X-axis direction of viewport to perform one-linescanning. The line scanning is completed, and thereafter, the stamp ismoved to the Y-axis direction so that it is moved along the next line.The foregoing operation is successively repeated, and thereby, pixeldata is generated.

If the rendering primitive is a segment, the segment is expanded by dpixel in a minor axis direction to form a parallelogram, and thereafter,the formed parallelogram is scanned. The minor axis means a shorter axisof X-axis and Y-axis after the segment is projected; on the contrary, alonger axis calls a major axis. The foregoing “d” value is usually setto 1.0; in this case, the value is made large, and thereby, a thinsegment is drawn. The parallelogram is scanned every stamp like the caseof the triangle. By doing so, the following processings are carried out.One is determination whether or not the pixel exists inside theparallelogram. Another is interpolation of interpolating the vertexparameter to obtain pixel parameter.

The conventional determination and interpolation described above arecarried out using the following coordinate (window coordinate). Thecoordinate (window coordinate) is obtained in a manner of projecting thevertex of rendering primitive in a modeled three-dimensional coordinatesystem on the window.

However, if the rendering primitive includes a vertex existingbackwardly from the viewpoint, the vertex is not projected on thewindow; as a result, it does not have window coordinate. In general, thefollowing processings are required to rasterize the foregoing renderingprimitive. Specifically, as seen from FIG. 21 and FIG. 22 (of JPN. PAT.APPLN. KOAKI Publication No. 2003-423797), the rendering primitive ispreviously cut along neighboring clip plane. The rendering primitive isdivided into part, which is projected on the viewport and part, which isnot projected on there. Then, the foregoing determination andinterpolation are carried out using part projected on the viewport only.

The foregoing processing of dividing the rendering primitive along theclip surface calls clipping. The clipping is complicated, and muchprocessings are required. For this reason, dedicated hardware isfrequently required; as a result, there is a possibility that the costbecomes high. For example, some rasterizing methods of requiring noclipping have been proposed as a technique of solving the foregoingproblem. The method is disclosed in U.S. Pat. No. 6,504,542, Marc Olanoand Trey Greer, “Triangle Scan Conversion using 2D HomogeneousCoordinates”, 1997, SIGGRAPH/Euro-graphics Workshop

In order to carry out the foregoing rasterizing methods requiring noclipping, a method of effectively searching a scan start point is newlyrequired. The inventors have proposed a technique disclosed in JPN. PAT.APPLN. KOAKI Publication No. 2003-423797. According to the technique, atriangle projection image including a vertex existing backwardly fromthe viewpoint is classified using the vertex homogeneous coordinate. Inaccordance with the classified result, the scan start point isdetermined.

However, the foregoing technique is provided on the assumption that therendering primitive is a triangle; for this reason, other renderingprimitives such as segments are not taken into consideration.

BRIEF SUMMARY OF THE INVENTION

The present invention has been made in view of the foregoingcircumstances. An object of the present invention is to providerendering apparatus, which can rasterize rendering primitive accordingto the same method as the case where the rendering primitive is atriangle even if the rendering primitive is a segment regardless of thestate whether or not one vertex of the segment exists backwardly from aviewpoint. Another object of the present invention is to providerendering processing method and computer program product, which canrasterize rendering primitive in the same manner as above.

According to an aspect of the present invention, there is provided arendering apparatus which comprises: a vertex input device which inputsvertex data including at least homogeneous coordinate and windowcoordinate relevant to two vertexes of a segment given as a renderingprimitive; a edge coefficient calculator which calculates an edgecoefficient of an edge function relevant to the outer side of aprojection area from the vertex data, the edge coefficient being acoefficient used for determining whether or not a pixel exists insidethe projection area generated when the segment is projected on theprojection plane; a bounding box calculator which calculates a boundingbox of the projection area on a projection plane from vertex data of atleast one of two vertexes and the edge coefficient; a determiner whichclassifies the projection area based on a combination of the edgecoefficient, and which determines scan start point and scan performingdirection of the bounding box in accordance with the classification; anda traverser which scans the bounding box from the scan start point togenerate pixel data.

According to another aspect of the present invention, there is provideda rendering processing method which comprises: inputting vertex dataincluding at least homogeneous coordinate and window coordinate relevantto two vertexes of a segment given as a rendering primitive; calculatingan edge coefficient of an edge function relevant to the outer side of aprojection area from the vertex data, the edge coefficient being acoefficient used for determining whether or not a pixel exists insidethe projection area generated when the segment is projected on theprojection plane; calculating a bounding box of the projection area onthe projection plane from vertex data of at least one of two vertexesand the edge coefficient; classifying the projection area based on acombination of the edge coefficient, and determining scan start pointand scan performing direction of the bounding box in accordance with theclassification; and scanning the bounding box from the scan start pointto generate pixel data.

According to yet another aspect of the present invention, there isprovided a computer program product storing a program for allowing acomputer to function as a rendering apparatus, the computer programproduct which comprises: inputting vertex data including at leasthomogeneous coordinate and window coordinate relevant to two vertexes ofa segment given as a rendering primitive; calculating an edgecoefficient of an edge function relevant to the outer side of aprojection area from the vertex data, the edge coefficient being acoefficient used for determining whether or not a pixel exists insidethe projection area generated when the segment is projected on theprojection plane; calculating a bounding box of the projection area onthe projection plane from vertex data of at least one of two vertexesand the edge coefficient; classifying the projection area based on acombination of the edge coefficient, and determining scan start pointand scan performing direction of the bounding box in accordance with theclassification; and scanning the bounding box from the scan start pointto generate pixel data.

BRIEF DESCRIPTION OF THE SEVERAL VIEWS OF THE DRAWING

FIG. 1 is a block diagram showing the configuration of a real-time CGprocessor 10 according to an embodiment of the present invention;

FIG. 2 is a block diagram showing the configuration of a setup section15;

FIG. 3 is a view showing data format of vertex data in which an edgecoefficient calculation unit 150 receives from a vertex data buffer 31;

FIG. 4 is a view showing perspective projection transformation,orthographic projection transformation and viewport transformationmatrixes;

FIG. 5 is a view to explain the geometric meaning of edge function on ahomogeneous coordinate system, and shows a triangular pyramid in athree-dimensional space;

FIG. 6 is a flowchart to explain the flow of edge calculation by theedge coefficient calculation unit 150;

FIG. 7A and FIG. 7B are each a flowchart to explain the flow of boundingbox calculation by a bounding box calculation unit 151;

FIGS. 8A to 8H are views to explain the geometric meaning of procedurestaken in FIG. 7B;

FIGS. 9A and 9B are views to explain the geometric meaning of procedurestaken in FIG. 7A;

FIGS. 10A to 10F are views showing three-dimensional segment projectionimage, that is, six parallelograms, and scan start point candidates ineach parallelogram;

FIG. 11 is a view showing a scan start point and a scan direction everythree-dimensional segment projection image, parallelogram expandingprojection image and bounding box pattern;

FIG. 12 is a view showing the scan start point and the scan directionevery three-dimensional segment projection image, parallelogramexpanding projection image and bounding box pattern;

FIG. 13 is a view showing the scan start point and the scan directionevery three-dimensional segment projection image, parallelogramexpanding projection image and bounding box pattern;

FIG. 14 is a view showing the scan start point and the scan directionevery three-dimensional segment projection image, parallelogramexpanding projection image and bounding box pattern;

FIG. 15 is a view showing the scan start point and the scan directionevery three-dimensional segment projection image, parallelogramexpanding projection image and bounding box pattern;

FIG. 16 is a view showing setup data generated in an edge functioninitial value determination unit 153; and

FIG. 17 is a flowchart to explain the operation flow by a setup section13.

DETAILED DESCRIPTION OF THE INVENTION

Embodiments of the present invention will be described below withreference to the accompanying drawings. In the following description,the same reference numerals are used to designate elements having theidentical function and configuration, and the overlapping explanationwill be made if necessary only.

FIG. 1 is a block diagram showing the configuration of a real-time CGprocessor (engine) 10 according to an embodiment of the presentinvention. As shown in FIG. 1, the graphic processor 10 includes vertexinput section 11, vertex processing section 12, rasterizing section 13,pixel processing section 17 and rendering memory 18.

The vertex input section 11 inputs vertex data of rendering primitivefrom a predetermined storage device.

The vertex processing section 12 makes an operation of predeterminedcoordinate transformation with respect to the vertex data inputted fromthe vertex input section 11.

The rasterizing section 13 carries out rasterizing to generate internalpixel data of rendering primitive from the vertex data processed by thevertex processing section 12. The vertex data inputted to therasterizing section 13 (i.e., data receiving from the vertex processingsection 12) is composed of vertex coordinate and vertex parameter. Thevertex coordinate shows the vertex position, and the vertex parametershows vertex attribute (e.g., color, texture, etc.). Moreover, therasterizing section 13 carries out the following processings. One isdetermination whether or not a pixel exists inside rendering primitiveusing the vertex coordinate. Another is interpolation of interpolatingthe vertex parameter to calculate pixel parameter.

More specifically, the rasterizing section 13 has vertex data buffer 14,setup section 15 and traverse section 16 as seen from FIG. 1. The vertexdata buffer 14 buffers vertex data inputted from the vertex inputsection 12. The setup section 15 acquires the vertex data of renderingprimitive from the vertex data buffer, and makes the foregoingdetermination based on the vertex data to generate setup data requiredfor rasterizing. The traverse section 16 carries out the foregoinginterpolation using the setup data supplied from the setup section 15 togenerate pixel data. The configuration and function of the setup section15 will be described later.

The pixel processing section 17 carries out a predetermined operationwith respect to the pixel data generated by the rasterizing section 13.

The rendering memory 18 stores pixel data processed by some pixelprocessing sections 17.

(Setup Section)

The configuration and function of the setup section 15 will be explainedbelow. FIG. 2 is a block diagram showing the configuration of the setupsection 15. As depicted in FIG. 2, the setup section 15 has edgecoefficient calculation unit 150, bounding box calculation unit 151,start point determination unit 152 and edge function initial valuecalculation unit 153. Specifically, the edge coefficient calculationunit 150 calculates coefficient (edge coefficient) of an edge function.The bounding box calculation unit 151 calculates a bounding box of aprojection image of rendering primitive. The start point determinationunit 152 determines pixel scan start point and performing direction. Theedge function initial value calculation unit 153 calculates an edgefunction value at a start pixel as a DDA initial value.

The following is an explanation about processing carried out by eachsection. In the following description, the case where renderingprimitive is a segment is given as an object.

(Edge Calculation by Edge Coefficient Calculation Section)

The edge coefficient calculation unit 150 acquires vertex data ofrendering primitive from the vertex buffer 14. The data format of thevertex data is as shown in FIG. 3. As seen from FIG. 3, the vertex datais composed of a vertex coordinate showing the vertex position and avertex parameter showing vertex attribute.

In this case, the vertex coordinate is inputted using a homogeneouscoordinate x, y, z, w, and not a window coordinate as used in theconventional case. The homogeneous coordinate is a coordinate made in amanner of multiplying arbitrary projection matrix and viewporttransformation matrix shown in FIG. 4 by a coordinate (viewingcoordinate) using the viewpoint as the origin. The vertex position ofthe rendering primitive is determined according to x, y and wcomponents. Moreover, z component is used to determine a depth valuewhen the rendering primitive is projected on the viewport.

If the rendering primitive has w components of all vertexes smaller than0, the vertex exists backwardly from the viewpoint. Thus, the procedureafter that may be skipped to acquire the vertex data of the nextrendering primitive. The following data, that is, color, R, G, B, A,texture coordinate s, t, r, q, fog f normal vector Nx, Ny and Nz areinputted as the vertex parameter.

Then, the unit 150 calculates an edge function coefficient based on theacquired vertex data of the rendering primitive. The procedure ofcalculating the edge function coefficient is taken in the followingmanner.

In general, the edge function (linear equation) on the window coordinatesystem is expressed using the following equation (5).

a×X+b×Y+c=0  (5)

Where,

(X, Y): window coordinate of arbitrary point on viewport

a, b, c: constant

In this case, the foregoing symbols (a, b) means a normal vector of theedge on the window coordinate system. The relationship between thehomogeneous coordinate (x, y, w) inputted to the rasterizing section 13and the window coordinate (X, Y) is expressed using the followingequation (6).

X=Sm×(x/w)+W/2

Y=Sm×(y/w)+H/2  (6)

Where,

Sm: half value of maximum screen size

W, H: width and height of viewport

The equation (6) is substituted for the equation (5), and thereby, thefollowing equation (7) is obtained.

a×(Sm×(x/w)+W/2)+b×(Sm×(y/w)+H/2)  (7)

When multiplying both sides of the equation (7) is multiplied by w anddeveloping it, the following equation is obtained.

a×Sm×x+a×(W/2)×w+b×Sm×y+b×(H/2)×w+c×w=0

When arranging the above-mentioned equation, the following equation isobtained.

(a×Sm)×x+(b×Sm)×y+(a×(W/2)+b×(H/2)+c)×w=0

Here, a7, b7 and c′ are replaced with the following equation (8).

a′=a×Sm

b′=b×Sm

c′=a×(W/2)+b×(H/2)+c  (8)

By doing so, the following equation (9) is obtained.

a′×x+b′×y+c′×w=0  (9)

The equation (9) expresses an edge function on the homogeneouscoordinate system x, y, w. The geometric meaning of the equation (9)will be described later. The following matter can be seen from theequation (8). Specifically, coefficients a, b and c of the edge functionof the window coordinate system are obtained from coefficients a′, b′and c′ of the edge function calculated using the homogeneous coordinatesystem.

a=a′/Sm

b=b′/Sm

c=C′(a×(W/2)+b×(H/2))  (10)

In this case, transformation of the coefficient c is realized even ifthe window coordinates X, Y substituted for the edge function of thewindow coordinate system of the equation (5) are shifted by X−W/2,Y−H/2. For confirmation, when substituting X−W/2, Y−H/2 for the equation(5), the following equation is obtained.

a×(X−W/2)+b×(Y−H/2)+c

When arranging the above-mentioned equation, the following equation (11)is obtained.

a×X+b×Y+(c−(a×(W/2)+b×(H/2)))+c=0  (11)

As described above, the window coordinates X, Y substituted for the edgefunction are shifted by X−W/2, Y−H/2, and thereby, transformation of thecoefficient c of the equation (10) is realized. Therefore,transformation from the homogeneous coordinate system of the equation(10) to the window coordinate system is simplified as shown in thefollowing equation (12).

a=a′/Sm

b=b′/Sm

c=C′  (12)

Incidentally, the window coordinates X, Y substituted for the edgefunction are shifted by X−W/2, Y−H/2. In this case, the windowcoordinates X, Y of rasterized each pixel may be shifted by X+W/2,Y+H/2.

The geometric meaning of the edge function of the homogeneous coordinatesystem of the equation (9) and the method of calculating coefficientsa′, b′ and c′ will be described. First, the method of calculatingcoefficients a′, b′ and c′ will be described below. When rewriting theequation (9) using a vector format, the following equation (13) isobtained.

(a′,b′,c′)·(x,y,w)=0  (13)

Where, symbol “·” denotes inner (scalar) product of vector.

The equation (13) shows an equation of the plane connecting viewpoint(0, 0, 0) in the (x, y, w) space and two points on the edge. Theforegoing (a′, b′, c′) shows a normal vector on the plane. If thehomogeneous coordinates at both end points of the edge are set as (x0,y0, w0), (x1, y1, w1), the normal vector (a′, b′, c′) on the plane iscalculated using the following equation (14).

(a′,b′,c′)=(x0,y0,w0)×(x1,y1,w1)  (14)

where, symbol “×” shows outer product of vector

The normal vector (a′, b′, c′) calculated from the homogeneouscoordinate at both end points of the edge according to the equation (14)is transformed using the equation (12). By doing so, coefficients a, band c of the edge function of the window coordinate system arecalculated.

The geometric meaning of the edge function of the homogeneous coordinatesystem of the equation (9) will be described below. When substitutingthe equation (14) for the equation (13), the following equation (15) isobtained.

((x0,y0,w0)×(x1,y1,w1))·(x,y,w)  (15)

The left side of the equation (15) is scalar triple product of vector(x0, y0, w0), (x1, y1, w1), (x, y, w). Therefore, the value is equal tosix times as much as a signed volume of a triangular pyramid connectingthe foregoing three points and the viewpoint (0, 0, 0).

FIG. 5A and FIG. 5B each show a triangular pyramid using (0, 0, 0), (x0,y0, w0), (x1, y1, w1), as the base and using (x, y, w) as a vertex. Thevolume sign of the triangular pyramid calculated according to the leftside is as shown in FIG. 5A and FIG. 5B. Specifically, the volume signis positive if an arbitrary point (x, y, w) exists in the same directionthe normal vector (a′, b′, c′) via the edge (case of FIG. 5A). On theother hand, the volume sign is negative if it exists in the directionreverse to above (case of FIG. 5B). Moreover, the volume sign becomeszero “0” if the arbitrary point (x, y, w) exists on the edge.Incidentally, the homogeneous coordinate system x, y, w is a left-handedsystem; for this reason, should be noted that the direction of thenormal vector (a′, b′, c′) becomes reverse to usual.

In other words, the edge function of the homogeneous coordinate systemrepresents a signed volume of the triangular pyramid. The sign isdetermined, and thereby, a pixel on the viewport corresponding to thevertex (x, y, w) is classified into three, that is, both side areas ofthe edge and area on the edge.

The procedure of calculating the edge coefficient is briefly described.Namely, the unit 150 calculates coefficients a′, b′ and c′ of the edgefunction of the homogeneous coordinate system from the homogeneouscoordinate relevant to the vertex of the rendering primitive receivedfrom the vertex processing section 12 using the equation (14). Moreover,the unit 150 transforms the coefficient value using the equation (12),and thereby, determines coefficients a, b and c of the edge function ofthe window coordinate system.

The coefficients a, b and c of the edge function are used fordetermining whether or not window coordinate X, Y points exist insiderendering primitive in the traverse section 16 although described later.

Moreover, the edge coefficient calculation unit 150 calculates abounding box edge function. The bounding box implies the minimum area ofa circumscribed rectangular area including graphics target, that is,rendering primitive.

In general, according to segment rasterizing, there is a need ofscanning a parallelogram made by expanding a segment by d pixel to theminor axis direction. In this embodiment, the edge function is used whendetermining whether or not a pixel exists inside two slant sides of theparallelogram. On the other hand, a parallelogram bounding box is usedwhen determining whether or not the pixel exists inside top and bottombases (or left and right sides) parallel with the minor axis. Accordingto the latter determination whether or not the pixel exists inside topand bottom bases (or left and right sides) parallel with the minor axis,the slant sides are moved in parallel by predetermined amount along theminor axis. The geometric information is readily grasped. Thus, the edgecoefficient calculation unit 150 calculates only edge function of twoslant sides of the parallelogram without calculating the edge functionof top and bottom bases (or left and right sides).

The edge coefficient calculation unit 150 calculates the edge functionsof two slant sides of the parallelogram in the following manner. Namely,the sign of the edge functions of the segment calculated using theequation (14) is controlled to move a pixel to the minor axis directionby d/2 in parallel. When the edge functions of two slant sides of theparallelogram in the homogeneous coordinate system are set as a0′, b0′,c0′ and a1′, b1′, c1′, the sign is expressed as shown in the followingequation (16).

a0′=−a′

b0′=−b′

c0′=−c′

a1′=a′

b1′=b′

c1′=c′  (16)

In the foregoing equation (16), coefficient signs of two edge functionscorresponding to slant sides are set to become mutually reverse. This isbecause of setting the edge function value of an area held between twoslant sides to become positive.

Then, the unit 150 transforms edge functions (a0′, b0′, c0′) and (a1′,b1 ′, c1′) in the homogeneous coordinates system into edge functions(a0, b0, c0) and (a1, b1, c1) in the window coordinate system.Transformation from the homogeneous coordinates system into the windowcoordinate system is carried out in the following manner using theequation (12).

a0=a0′/Sm

b0=b0′/Sm

c0=c0′

a1=a1′/Sm

b1=b1′/Sm

c1=c1′  (17)

In order to move two slant sides to the minor axis direction by d/2pixel, the unit 150 makes an addition such as the following equation(18) with respect to constant items c0, c1 of the coefficients of theedge functions.

C0+=fabs(dX×a0)+fabs(dY×b0)

C1+=fabs(dX×a0)+fabs(dY×b0)  (18)

In this case, dX=0, dY=d/2 are given when the major axis is the X-axis;on the other hand, dX=d/2, dY=0 are given when the major axis is theY-axis. Moreover, the symbol “fabs” represents a function for returningthe absolute value. According to the addition, the edge function valueof an area held between two slant sides becomes positive because twoslant sides are moved in parallel to the direction reverse to thenormal.

The flowchart to explain the procedure of calculating the edgecoefficient described above is shown in FIG. 6. In the first step S201;the coefficient of the edge function of the homogeneous coordinatesystem of the segment is calculated using the equation (14). In stepS202, coefficients of two edge functions having mutually reversed signare calculated using the equation (16). In step S203, the coefficientsof the edge functions are transformed from the homogeneous coordinatesystem into the window coordinate system using the equation (17). Thecoefficients are calculated via the homogeneous coordinate system. Bydoing so, even if a segment including a vertex existing backwardly fromthe viewpoint is given, the coefficients of the edge functions of thewindow coordinate system are obtained without carrying out clipping. Inthe final step S204, two edge functions are moved in parallel to theminor axis direction by d/2 using the equation (18). By doing so, it ispossible to find edge functions of two slant sides of the parallelogramexpanding the segment by d pixel in the minor axis direction.

(Bounding Box Calculation by Bounding Box Calculation Section)

The bounding box calculation of rendering primitive carried out by theby bounding box calculation section will be explained below. If therendering primitive is a segment, the bounding box has a circumscribedrectangular shape of a parallelogram expanding a projection image of thesegment to the minor axis direction.

In general, the bounding box is simply calculated by finding minimum andmaximum values of X and Y components of the window coordinate on thevertexes at both sides of the segment. However, if one vertex of thesegment exists backwardly from the viewpoint, the vertex is notprojected on the window; as a result, it becomes infinity. For thisreason, consideration for calculating the bounding box must be taken. Inthe rendering apparatus 10, the bounding box is calculated in thefollowing manner.

FIG. 7A and FIG. 7B are each a flowchart to explain the procedure ofcalculating the bounding box. In the first step S301 of FIG. 7A; thebounding box is initialized. The bounding box is expressed using windowcoordinate (Xmin, Ymin) at the upper left corner point and windowcoordinate (Xmax, Ymax) at the lower right corner point. Here,initialization is carried out in a manner that the window coordinate(Xmin, Ymin)=(−W/2, −H/2), and the window coordinate (Xmax,Ymax)=(W/2−1, −H/2−1). In this case, W and H denote width and height ofthe viewport.

In step S302, it is determined whether or not w component of one vertex(x0, y0, w0) of the segment is larger than 0. If the w component islarger than 0, the flow proceeds to step S303; on the other hand, if itis less than 0, one vertex exists backwardly from the viewpoint. Thus,steps S303 and S304 are skipped, and thereafter, the flow proceeds tostep S305.

In step S303, the widow coordinate (X0, Y0) is calculated using theequation (6). In step S304, the calculated widow coordinate (X0, Y0) isset as (X, Y) and coefficients a0, b0 of the edge function are set as a,b, and thereafter, the procedure of calculating the corner point istaken. According to the foregoing procedure, rendering primitive, thatis, segment is classified according to combination of the gradient(coefficient) of the edge function. A value initialized in accordancewith the classification is corrected, and thereby, the corner point ofthe bounding box is determined.

FIG. 7B is a flowchart to explain the flow of calculating the cornerpoint. In the first step S401 of FIG. 7B, it is determine whether or notthe coefficient “a” of the edge function is more than 0 and thecoefficient “b” thereof is less than 0. If the foregoing condition issatisfied, the flow proceeds to step S402. On the other hand, if thecondition is not satisfied, the step S402 is skipped, and thereafter,the flow proceeds to step S403.

In step S402, the window coordinate (Xmin, Ymin) at the upper leftcorner of the bounding box is updated. In this case, dX and dY have thesame value as the equation (18); in other words, if the major axis isthe X-axis, dX=0, dY=d/2 while if it is Y-axis, dX=d/2, dY=0.

In step S403, it is determine whether or not the coefficient “a” of theedge function is less than 0 and the coefficient “b” thereof is morethan 0. If the foregoing condition is satisfied, the flow proceeds tostep S404. On the other hand, if the condition is not satisfied, thestep S404 is skipped, and thereafter, the flow proceeds to step S405. Instep S404, the window coordinate (Xmax, Ymax) at the lower right cornerof the bounding box is updated.

In step S405, it is determined whether or not coefficients “a” and “b”of the edge function are larger than 0. If the foregoing condition issatisfied, the flow proceeds to step S406. On the other hand, if thecondition is not satisfied, the step S406 is skipped, and thereafter,the flow proceeds to step S407. In step S406, the window coordinate(Xmax, Ymax) at the upper right corner of the bounding box is updated.

In step S407, it is determined whether or not coefficients a and b ofthe edge function are smaller than 0. If the foregoing condition issatisfied, the flow proceeds to step S408. On the other hand, if thecondition is not satisfied, the step S408 is skipped, and thereafter,the flow ends. In step S408, the window coordinate (Xmin, Ymin) at thelower left corner of the bounding box is updated.

The foregoing procedure of FIG. 7B is based on consideration such thatthe edge normal (a, b) calculated using the equations (16) and (17) isdirected to the left side toward another vertex from the target vertex.The geometric meaning of the foregoing procedure will be explained belowwith reference to FIGS. 8A to 8H.

Specifically, steps S401 and S402 of FIG. 7B are equivalent to theprocedure of the case where the vertex exists at the upper left cornerpoint of the bounding box a shown in FIGS. 8C, 8E and 8H. Steps S403 andS404 of FIG. 7B are equivalent to the procedure of the case where thevertex exists at the lower right corner point of the bounding box ashown in FIGS. 8A, 8G and 8F. Likewise, steps S405 and S406 of FIG. 7Bare equivalent to the procedure of the case where the vertex exists atthe upper right corner point of the bounding box a shown in FIG. 8D.Steps S407 and S408 of FIG. 7B are equivalent to the procedure of thecase where the vertex exists at the lower left corner point of thebounding box a shown in FIG. 8B.

If a=b=0, the vertexes at both sides of the segment coincides with eachother. Thus, the procedure is interrupted after coefficient calculationof the edge function in step S401 of FIG. 7B, and then, the procedurefor the next segment may be taken. Even if the procedure is notinterrupted, the area of the bounding box becomes zero “0”; therefore,no drawing is carried out. Thus, the procedure taken so far is notbroken.

The flowchart of FIG. 7A will be again explained. When the procedure ofstep S304 is completed, it is determined in the nest step S305 whetheror not w component of another vertex (x1, y1, w1) of the segment islarger than 0. If the w component is larger than 0, the flow proceeds tostep S306; on the other hand, if it is less than 0, another vertex (x1,y1, w1) of the segment exists backwardly from the viewpoint. Thus, stepsS306 and S307 are skipped, and thereafter, the procedure ends.

In step S306, the widow coordinate (X1, Y1) is calculated using theequation (6). In step S307, the calculated widow coordinate (X1, Y1) isset as (X, Y) and coefficients a1, b1 of the edge function are set as a,b, and thereafter, the procedure of calculating the corner point of FIG.7B is taken.

When the foregoing procedures taken in steps S301 to S307 is completed,(Xmin, Ymin) represents the window coordinate at the upper left cornerpoint of the bounding box while (Xmax, Ymax) represents the windowcoordinate at the lower right corner point thereof.

The geometric meaning of the procedure of calculating the bounding boxhaving a parallelogram according to the flow of FIG. 7A will beexplained with reference to FIG. 7A, FIG. 9A and FIG. 9B. FIG. 9A is aview to explain the geometric meaning of the case where the segmentexists forwardly from the viewpoint (i.e., w component of both vertexesof the segment is positive).

In step S301, the bounding box is initialized, and an initial boundingbox is set.

In steps S302 to S304, the procedure of calculating the corner point ofFIG. 7B is taken with respect to coefficients a0, b0 of the edgefunction corresponding to the window coordinate X0, Y0 of the vertex.The window coordinate (Xmax Ymax) at the lower right corner point of thebounding box is updated.

In steps S305 to S307, the procedure of calculating the corner point ofFIG. 7B is taken with respect to coefficients a1, b1 of the edgefunction corresponding to the window coordinate X1, Y1 of anothervertex. The window coordinate (Xmin Ymin) at the upper left corner pointof the bounding box is updated. As a result, the upper left corner point(X1, Y1−d/2) of the bounding box and the lower right corner point (X0,Y0+d/2) thereof are calculated.

FIG. 9B is a view to explain the geometric meaning of the case where onevertex of the segment exists forwardly from the viewpoint (i.e., wcomponent of one vertex of the segment is less than 0).

In step S301, the bounding box is initialized, and an initial boundingbox is set.

In steps S302 to S304, the procedure of calculating the corner point ofFIG. 7B is taken with respect to coefficients a0, b0 of the edgefunction corresponding to the window coordinate X0, Y0 of the vertex.The window coordinate (Xmax Ymax) at the upper right corner point of thebounding box is updated.

In steps S305, it is determined that w1≦0; therefore, steps S306 andS307 are skipped. As a result, the upper left corner point (−W/2, Y0) ofthe bounding box and the lower right corner point (X0+d/2, H/2−1)thereof are calculated.

Thus, the bounding box initialized in step S301 is corrected into asmaller size in accordance with the side of the segment (i.e.,parallelogram expanding projection image of the segment to the minoraxis direction). As a result, this serves to effectively generate pixeldata in the traverse section 16.

In particular, according to the method described above, if one vertex ofthe segment exists backwardly from the viewpoint, the initializedbounding box is divided into two areas using the following two lines.One is a straight line parallel with the minor axis passing throughanother vertex existing forwardly from the viewpoint. Another is astraight line parallel with the major axis passing through anothervertex existing forwardly from the viewpoint. In this case, theinitialized bounding box is corrected into a smaller size to delete thearea including no segment in the divided two areas. By doing so, even ifone vertex of the segment exists backwardly from the viewpoint, anoptimized bounding box is always set.

(Start Point and Performing Direction Determination by Start PointDetermination Unit 152)

The procedure of determining the scan start point and the scanperforming direction by the start point determination unit 152 will beexplained below.

In general, a projection image of a three-dimensional segment isclassified into six parallelograms. Thus, in the rendering apparatus 10,the scan start point and the scan performing direction are determined inaccordance with the classification.

FIGS. 10A to 10F are views showing three-dimensional segment projectionimage, that is, six parallelograms, and scan start point candidates ineach parallelogram. As shown in FIG. 10A and FIG. 10B, if theparallelogram is vertical or horizontal scan may be started from anypoints of four corners of the parallelogram. As shown in FIG. 10C andFIG. 10D, if the parallelogram is inclined to the upper left (lowerright) direction, scan is started from the upper left corner or lowerright corner of the parallelogram. As shown in FIG. 10E and FIG. 10F, ifthe parallelogram is inclined to the upper right (lower left) direction,scan is started from the upper right corner or lower left corner of theparallelogram.

In order to know whether the three-dimensional segment inputted to therasterizing section is projected to any of six parallelograms, the XYcomponent of the window coordinate at both vertexes is compared in itsmagnitude. However, if one vertex of the segment exists backwardly fromthe viewpoint, the vertex is not projected on the window; for thisreason, it is impossible to compare the window coordinate in itsmagnitude. Thus, in the rendering apparatus 10, the corner point setwhen calculating the bounding box is selected as the scan start point.

Specifically, in the case of FIG. 9A, the lower right corner point andthe upper left corner point of the parallelogram are determined.Therefore, one of the foregoing two corner points is selected as thescan start point. In the case of FIG. 9B, the upper right corner pointof the parallelogram is determined. Therefore, the foregoing point isselected as the scan start point. According to the method describedabove, the scan start point is determined even if one vertex of thesegment exists backwardly from the viewpoint.

The scan direction is determined in accordance with the scan startpoint. Specifically, if the start point is the upper left corner of theparallelogram, the scan direction is set to the lower right direction.If the start point is the lower left corner of the parallelogram, thescan direction is set to the upper right direction. If the start pointis the lower right corner of the parallelogram, the scan direction isset to the upper left right direction. If the start point is the upperright corner of the parallelogram, the scan direction is set to thelower left direction. The scan direction starts from the scan startpoint, and is set to the diagonal direction of the bounding box.

FIG. 11 to FIG. 15 is a view showing the scan start point and the scandirection every three-dimensional segment projection image,parallelogram expanding projection image and bounding box pattern. Inany patterns, scan start points given as candidate (recommended) arecorner points of the bounding box, that is, vertex position ofparallelogram expanding projection image of the three-dimensionalsegment. The scan direction starts from the scan start point, and is setto the diagonal direction of the bounding box.

(Edge Function Initial Value Determination by Edge Function InitialValue Determination Unit 153)

When the scan start point and the performing direction are determined,the edge function initial value determination unit 153 calculates anedge function value in a start pixel (X, Y) as a DDA initial value usingthe equation (5). The unit 153 generates setup data together withalready calculated edge coefficient and bounding box value.

FIG. 16 shows the setup data generated by the edge function initialvalue determination unit 153. The traverse section 16 connected to theafter-stage of the setup section 15 inputs setup data from the setupsection 15. Then, the traverse section 16 carries out DDA ofsuccessively adding coefficients of the edge function to the initialvalue to determine an edge function value of each pixel.

(Procedure by Setup Section 13)

FIG. 17 is a flowchart to explain the operation flow of the setupsection 13. Referring now to FIG. 17, the procedure taken by the setupsection 13 will be described below. The details of the procedure takenin each step are as already described.

As depicted in FIG. 17, the setup section 13 acquires vertex data havingthe format shown in FIG. 3 from the vertex data buffer 14 (step S101).

The edge coefficient calculation unit 150 calculates an edge coefficientof the homogeneous coordinate system with respect to renderingprimitive, that is, segment according to the procedure shown in FIG. 6.Based on the foregoing coefficient, the unit 150 calculates windowcoordinate of the corresponding edge coefficient and edge functions oftwo slant sides of the parallelogram expanding the segment by d pixel tothe minor axis direction (step S102).

The bounding box calculation unit 151 calculates a bounding box having aparallelogram according to the procedure shown in FIG. 7A and FIG. 7B(step S103). The unit 151 calculates a parallelogram bounding boxexpanding the segment by d pixel to the minor axis direction based onthe obtained edge coefficient of segment and edge functions of two slantsides of the parallelogram.

The start point determination unit 152 classifies the parallelogram intosix kinds. Thereafter, the unit 152 determines scan start point andperforming direction in accordance with the classification in the mannerdescribed in FIG. 10 to FIG. 15 (step S104).

The edge function initial value determination unit 153 calculates anedge function value in a start pixel (X, Y) as a DDA initial value usingthe equation (5). Thereafter, the unit 153 generates setup data togetherwith already calculated edge coefficient and bounding box value. Thesetup data thus generated is sent to the traverse section 16 (stepS105).

According to the configuration described above, the following effectscan be obtained.

The rendering apparatus of this embodiment calculates the edgecoefficient of the homogeneous coordinate system, and transforms it tocalculate the edge coefficient of the window coordinate system.Therefore, even if rendering primitive is a segment, it is possible torasterize rendering primitive according to the same method as the casewhere the rendering primitive is a triangle regardless of the statewhether or not one vertex of the segment exists backwardly from aviewpoint without clipping.

If at least part of the segment exists forwardly from the viewpoint, therendering apparatus of this embodiment calculates the bounding boxcircumscribing the projection image of the segment using the windowcoordinate of at least one of both vertexes of the segment. Therefore,even if one vertex of the segment exists backwardly from the viewpoint,the bounding box is set using the same method. Moreover, the obtainedbounding box is reduced depending on the projection image size of thesegment and the state whether or not one end of the segment existsbackwardly from the viewpoint. Therefore, the bounding box thus set ismade small as much as possible, and thus, rasterizing is effectivelyachieved.

The rendering apparatus of this embodiment classifies the projectionimage of the segment based on the combination of edge coefficient. Then,the rendering apparatus determines scan start point and scan performingdirection of the bounding box in accordance with the foregoingclassification. Therefore, even if rendering primitive is a segment, itis possible to effectively determine the scan start point and the scanperforming direction according to the same method as the case where therendering primitive is a triangle regardless of the state whether or notone vertex of the segment exists backwardly from a viewpoint.

Additional advantages and modifications will readily occur to thoseskilled in the art. Therefore, the invention in its broader aspects isnot limited to the specific details and representative embodiments shownand described herein. Accordingly, various modifications may be madewithout departing from the spirit or scope of the general inventiveconcept as defined by the appended claims and their equivalents.

1. A rendering apparatus, comprising: a vertex input device which inputsvertex data including at least homogeneous coordinate and windowcoordinate relevant to two vertexes of a segment given as a renderingprimitive; an edge coefficient calculator which calculates an edgecoefficient of an edge function relevant to the outer side of aprojection area from the vertex data, the edge coefficient being acoefficient used for determining whether a pixel exists inside theprojection area generated when the segment is projected on theprojection plane; a bounding box calculator which calculates a boundingbox of the projection area on a projection plane from vertex data of atleast one of two vertexes and the edge coefficient; a determiner whichclassifies the projection area based on a combination of the edgecoefficient, and which determines scan start point and scan performingdirection of the bounding box in accordance with the classification; atraverser which scans the bounding box from the scan start point togenerate pixel data; pixel processor processing a predeterminedoperation with respect to the pixel data; and a rendering memory storingthe pixel data processed by the pixel processor, wherein the edgecoefficient calculator calculates the edge coefficient based on thehomogeneous coordinates of two vertexes, and the bounding box calculatordetermines whether at least part of the segment exists forwardly fromthe reference viewpoint based on the homogeneous coordinates of twovertexes, and if it is determined that part of the segment existsforwardly from a reference viewpoint, calculates a bounding box of aprojection image of the segment using at least one window coordinate oftwo vertexes.
 2. The rendering apparatus according to claim 1, whereinthe bounding box calculator determines whether one vertex of the segmentexists backwardly from the reference viewpoint, divides an initializedbounding box into a first area including the segment and a second areaincluding no segment by using a first straight line and a secondstraight line if it is determined that one vertex of the segment existsbackwardly from the reference viewpoint, the first straight line beingparallel with a vertical axis of a window coordinate system passingthrough another vertex existing forwardly from the reference viewpoint,and the second straight line parallel with a horizontal axis of thewindow coordinate system passing through another vertex, and makessmaller the initialized bounding box so that the second area is deleted.3. The processor according to claim 1, wherein the determiner determinesa scan start point which is a corner of the bounding box and any of thevertexes of the projection area, based on the classification, anddetermines a direction from the scan start point to an inside of theprojection area as a scan direction.
 4. A rendering apparatus,comprising: a vertex input device which inputs vertex data including atleast homogeneous coordinate and window coordinate relevant to twovertexes of a segment given as a rendering primitive; an edgecoefficient calculator which calculates an edge coefficient of an edgefunction relevant to the outer side of a projection area from the vertexdata, the edge coefficient being a coefficient used for determiningwhether a pixel exists inside the projection area generated when thesegment is projected on the projection plane; a bounding box calculatorwhich calculates a bounding box of the projection area on a projectionplane from vertex data of at least one of two vertexes and the edgecoefficient; a determiner which classifies the projection area based ona combination of the edge coefficient, and which determines scan startpoint and scan performing direction of the bounding box in accordancewith the classification; a traverser which scans the bounding box fromthe scan start point to generate pixel data; a pixel processorprocessing a predetermined operation with respect to the pixel data; anda rendering memory storing the pixel data processed by the pixelprocessor, wherein the projection area is a parallelogram generated in amanner of moving a projection image on the projection plane of thesegment in parallel to a minor axis direction, which is an axis having ashorter length when the segment is projected on vertical and horizontalaxes of the projection plane.